package com.ruoyi.repair.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.repair.domain.PropertyRepairLog;
import com.ruoyi.repair.service.IPropertyRepairLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报修进度日志Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/repair/logRepair")
public class PropertyRepairLogController extends BaseController
{
    @Autowired
    private IPropertyRepairLogService propertyRepairLogService;

    /**
     * 查询报修进度日志列表
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyRepairLog propertyRepairLog)
    {
        startPage();
        List<PropertyRepairLog> list = propertyRepairLogService.selectPropertyRepairLogList(propertyRepairLog);
        return getDataTable(list);
    }

    /**
     * 导出报修进度日志列表
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:export')")
    @Log(title = "报修进度日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyRepairLog propertyRepairLog)
    {
        List<PropertyRepairLog> list = propertyRepairLogService.selectPropertyRepairLogList(propertyRepairLog);
        ExcelUtil<PropertyRepairLog> util = new ExcelUtil<PropertyRepairLog>(PropertyRepairLog.class);
        util.exportExcel(response, list, "报修进度日志数据");
    }

    /**
     * 获取报修进度日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return success(propertyRepairLogService.selectPropertyRepairLogByLogId(logId));
    }

    /**
     * 新增报修进度日志
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:add')")
    @Log(title = "报修进度日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyRepairLog propertyRepairLog)
    {
        return toAjax(propertyRepairLogService.insertPropertyRepairLog(propertyRepairLog));
    }

    /**
     * 修改报修进度日志
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:edit')")
    @Log(title = "报修进度日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyRepairLog propertyRepairLog)
    {
        return toAjax(propertyRepairLogService.updatePropertyRepairLog(propertyRepairLog));
    }

    /**
     * 删除报修进度日志
     */
    @PreAuthorize("@ss.hasPermi('repair:logRepair:remove')")
    @Log(title = "报修进度日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(propertyRepairLogService.deletePropertyRepairLogByLogIds(logIds));
    }
}
